<template>
  <div style="height: 100%;">
      <div class="content-com" v-if="msgtype==1" :key="datas.datakey">
          <his-interface></his-interface>
      </div>
      <div class="content-com" v-else-if="msgtype==2" :key="datas.datakey">
          <!--仪器危急值-->
          <rm-instralertinfo :tabledata="datas.instrdatas" :params="params" @change="changeEvent(msgtype)"></rm-instralertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==3" :key="datas.datakey">
          <!--设备维护保养-->
          <rm-devalertinfo :tabledata="datas.devdatas" @change="changeEvent(msgtype)"></rm-devalertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==4" :key="datas.datakey">
          <!--申请单计价失败-->
          <!--申请单计价失败改为直接弹窗，不是点击消息弹窗 -->
      </div>
      <div class="content-com" v-else-if="msgtype==5" :key="datas.datakey">
          <!--报告超时-->
          <rm-rpttimeoutalertinfo :tabledata="datas.rpttimeoutdatas" :params="params" @change="changeEvent(msgtype)"></rm-rpttimeoutalertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==6" :key="datas.datakey">
          <!--超过预警时间还未上机的标本-->
          <rm-getovertimenoinputalertinfo :tabledata="datas.overtimenoinputdatas" :params="params" @change="changeEvent(msgtype)"></rm-getovertimenoinputalertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==7" :key="datas.datakey">
          <!--危急值上报后几分钟临床未确认自动提醒检验科电话通知-->
          <rm-noconfirmalertinfo :tabledata="datas.noconfirmdatas" :params="params" @change="changeEvent(msgtype)"></rm-noconfirmalertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==9" :key="datas.datakey">
          <!--即将考试通知-->
          <rm-exmusralertinfo :tabledata="datas.exmdatas" :params="params" @change="changeEvent(msgtype)"></rm-exmusralertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==10" :key="datas.datakey">
          <!--开瓶试剂过期通知-->
          <rm-invuseexpirydtwarn :tabledata="datas.useexpirydatas" :params="params" @change="changeEvent(msgtype)"></rm-invuseexpirydtwarn>
      </div>
      <div class="content-com" v-if="msgtype==11" :key="datas.datakey">
          <!--西安交大一附院自动推送exe死亡判定消息提醒-->
          <div style="text-indent:2em;font-size:50px;color:red">{{rcvparams.msgcontent}}</div>
      </div>
      <div class="content-com" v-if="msgtype==13" :key="datas.datakey">
          <vxe-table show-overflow ref="xTable" :data.sync="datas.dbtbindexdatas" height="auto" width="100%" border size="mini" :select-config="{ reserve: true }" show-header-overflow resizable header-align="center" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" key="1">
              <vxe-table-column field="indexname" title="索引" width="170" align="center"></vxe-table-column>
              <vxe-table-column field="ldc_percent" title="百分比" width="120" header-align="center" align="right"></vxe-table-column>
              <vxe-table-column field="ldc_size" title="大小" width="120" header-align="center" align="right"></vxe-table-column>
          </vxe-table>
      </div>
      <div class="content-com" v-else-if="msgtype==14" :key="datas.datakey">
          <!--仪器危急值-->
          <rm-backtaskfailalertinfo :tabledata="datas.taskdatas" :params="params" @change="changeEvent(msgtype)"></rm-backtaskfailalertinfo>
      </div>
      <div class="content-com" v-if="msgtype==15" :key="datas.datakey">
          <!--检验科标本超时未送达自动提醒-->
          <rm-checkdeptouttimealertinfo :tabledata="datas.outtimedatas" :params="params" @change="changeEvent(msgtype)"></rm-checkdeptouttimealertinfo>
      </div>
      <div class="content-com" v-else-if="msgtype==16" :key="datas.datakey">
          <!--发送消息消息通知提醒-->
          <rm-sendmsginforec :tabledata="datas.taskdatas" :params="params" @change="changeEvent(msgtype)"></rm-sendmsginforec>
      </div>
      <div class="content-com" v-else-if="msgtype==17" :key="datas.datakey">
          <!--血培养报阳未处理自动提醒-->
          <rm-bactalert :alertlist="datas.posdatas"></rm-bactalert>
      </div>
  </div>
</template>

<script type="text/javascript">
import HisInterface from "@/components/rmcompents/msgcenter/HisInterface.vue";
import RmDevalertinfo from "@/components/rmcompents/rmdev/rm_devalertinfo.vue";
import RmInstralertinfo from "@/components/rmcompents/msgcenter/rm_instrnoalertinfo.vue";
import RmRpttimeoutalertinfo from "@/components/rmcompents/msgcenter/rm_rpttimeoutalertinfo.vue";
import RmGetovertimenoinputalertinfo from "@/components/rmcompents/msgcenter/rm_getovertimenoinputalertinfo.vue";
import RmNoconfirmalertinfo from "@/components/rmcompents/msgcenter/rm_getnoconfirmalertinfo.vue";
import RmInvuseexpirydtwarn from "@/components/rmcompents/rminv/rm_invuseexpirydtwarn.vue";
import RmExmusralertinfo from "@/components/rmcompents/msgcenter/rm_exmusralertinfo.vue";
import RmBacktaskfailalertinfo from "@/components/rmcompents/msgcenter/rm_backtaskfailalertinfo.vue";
import RmCheckdeptouttimealertinfo from "@/components/rmcompents/msgcenter/rm_checkdeptouttimealertinfo.vue";
import RmBactalert from "@/components/rmcompents/rmsampleinfo/rm_bactalert.vue";

export default {
  name: "msgcenter",
  props: {
      params: { type: Object },
  },
  components: {
      HisInterface,
      RmDevalertinfo,
      RmInstralertinfo,
      RmRpttimeoutalertinfo,
      RmGetovertimenoinputalertinfo,
      RmNoconfirmalertinfo,
      RmInvuseexpirydtwarn,
      RmExmusralertinfo,
      RmBacktaskfailalertinfo,
      RmCheckdeptouttimealertinfo,
      RmBactalert,
  },
  data() {
      return {
          webbrowser: typeof jsObj != "undefined",
          msgtype: "", //this.$route.params.p1,
          rcvparams: this.params,
          datas: { datakey: 0, devdatas: [], instrdatas: [], reqchargedatas: [], overtimenoinputdatas: [], noconfirmdatas: [], useexpirydatas: [], exmdatas: [],posdatas:[], },
      };
  },
  created() {
      console.log("sa", this.rcvparams);
      this.msgtype = this.rcvparams.msgtype;
      switch (this.msgtype) {
          case 1: //HIS接口消息提醒
              break;
          case 2: //仪器危急值提醒
              this.initlabInstrAlertData();
              break;
          case 3: //设备维护保养消息提醒
              this.initDevAlertData();
              break;
          case 4: //申请单计价失败消息（已移走，直接弹窗）
              //this.initReqChargeData();
              break;
          case 5: //报告超时或接近超时提醒
              this.initRpttimeoutData();
              break;
          case 6: //超过预警时间还未上机的标本
              this.initovertimenoinputData();
              break;
          case 7: //危急值上报后几分钟临床未确认自动提醒检验科电话通知
              this.initnoconfirmData();
          case 8: //申请单计价失败提醒
              break;
          case 9: //即将考试通知
              this.initExmData();
              break;
          case 10: //开瓶试剂过期通知
              this.initUseExpiryData();
              break;
          case 13: //  数据库表索引过大提醒
              this.initDbtableIndexData();
              break;
          case 14:
              this.initBackTaskFailData();
              break;
          case 15: //检验科标本超时未送达自动提醒
              this.initCheckDeptOutTimeGetData();
              break;
          case 17://血培养报阳未处理自动提醒
              this.initBloodCulturePosGetData();
              break;
          default:
              break;
      }
  },
  methods: {
      //初始化仪器危急值提醒信息
      initlabInstrAlertData() {
          this.initComPost()
              .then((res) => {
                  this.datas.instrdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      //初始化设备管理提醒信息
      initDevAlertData() {
          this.$tool
              .request({
                  url: "ucent/devalert",
                  method: "post",
                  data: {
                      action: "showdevplanlist",
                  },
              })
              .then((res) => {
                  this.datas.devdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      //初始化报告超时或接近超时信息
      initRpttimeoutData() {
          this.initComPost()
              .then((res) => {
                  this.datas.rpttimeoutdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      //超过预警时间还未上机的标本
      initovertimenoinputData() {
          this.initComPost()
              .then((res) => {
                  this.datas.overtimenoinputdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      //危急值上报后几分钟临床未确认自动提醒检验科电话通知
      initnoconfirmData() {
          this.initComPost()
              .then((res) => {
                  this.datas.noconfirmdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      //开瓶试剂过期通知
      initUseExpiryData() {
          this.initComPost()
              .then((res) => {
                  this.datas.useexpirydatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      //即将考试通知
      initExmData() {
          this.initComPost()
              .then((res) => {
                  this.datas.exmdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      // 数据库表索引过大提醒
      initDbtableIndexData() {
          this.initComPost()
              .then((res) => {
                  this.datas.dbtbindexdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      // 后台任务失败信息
      initBackTaskFailData() {
          this.initComPost()
              .then((res) => {
                  this.datas.taskdatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      // 检验科标本超时未送达自动提醒消息
      initCheckDeptOutTimeGetData() {
          this.initComPost()
              .then((res) => {
                  this.datas.outtimedatas = res.data;
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      // 血培养报阳未处理自动提醒
      initBloodCulturePosGetData() {
          this.initComPost()
              .then((res) => {
                  console.log("【initBloodCulturePosGetData】",res);
                  this.datas.posdatas = res.data;
                  
                  this.datas.datakey++;
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      initComPost() {
          return this.$tool.request({
              url: "ucent/alertmsg",
              method: "post",
              data: {
                  params: this.rcvparams.paramlist,
              },
          });
      },
      changeEvent(msgflag) {
          switch (msgflag) {
              case 1:
                  break;
              case 2: //仪器危急值提醒
                  this.$emit("change", "close");
                  break;
              case 3: //设备维护
                  this.$emit("change", "close");
                  break;
              case 4: //申请单计价失败(已移走)
                  //this.$emit("change", "close");
                  break;
              default:
                  this.$emit("change", "close");
                  break;
          }
      },
  },
};
</script>

<style scoped>
.broswer-tool {
  display: flex;
  justify-content: flex-end;
  line-height: 25px;
}
.tool-btn {
  margin-right: 10px;
}
.broswer-content {
  height: calc(100% - 25px);
}
.content-com {
  height: 100%;
}
</style>
